<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>每日签到</title>

	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/yzl.css" />

	<style>
		.username-warn {
			font-size: 12px;
			margin: 20px 15px;
		}

		.username-warn>span {
			background-size: 22px 22px;
			background-position: left center;
			background-repeat: no-repeat;
			padding-left: 22px;
		}

		.username-warn>span.big {
			background-image: url(../../image/big/username_icon_warn.png);
		}

		.username-warn>span.small {
			background-image: url(../../image/small/username_icon_warn.png);
		}
	</style>

</head>

<body>
	<div id="blank" class="header">
		<div v-back.tapmode class="back"></div>
		<span class="title">每日签到</span>
	</div>
	<div id="app" class="main-container" v-cloak>
		<div style="text-align: center;margin-top: 50px;color:#666">每日签到赢CC,邀请好友获取更多哟</div>
		<a class="btn-commit" v-myclick="sign" v-show="!signinfo">签到</a>
		<a class="btn-commit disabled"  v-show="signinfo">今日已签到</a>
	</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script>
	var user;
	var signinfo;
	var hotsspAds;
	apiready = function () {
		setBSImg();
		new Vue({
			el: '#blank'
		});
        showProgress();
        var data = {
            member_id: getPrefs('member_id')
        };
        var callback = function (ret) {
            signinfo = ret.content;
            initApp();
            api.parseTapmode();
        };
        pinet.post(URL.getsign, data, callback);
		addListeners();
	};

	function initApp() {
		var vm = new Vue({
			el: '#app',
			data: {
				signinfo:signinfo,
				BSImg: {
					big: Vue.BSImg == 'big',
					small: Vue.BSImg == 'small'
				}
			},
			watch: {
				nickname: function (n, o) {
					this.nameByte = n.replace(/[^\x00-\xff]/g, "xx").length;
					if (this.nameByte > 24) {
						this.nickname = o;
					}
				}
			},
			methods: {
				sign: function () {
					showProgress();
					var data = {
						member_id: getPrefs('member_id'),

					};
					var callback = function (ret) {
						vm.signinfo = true;
						api.toast({
							msg:'签到成功'
						})
						api.sendEvent({
                        name : 'upduser',
                      });
					};
					pinet.post(URL.setsign, data, callback);
				},
			},
			mounted: function () {

			},
			watch:{
				nickname(name){
					if( /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig.test(name)){
						api.alert({
							title: '提示',
							msg: '昵称中不能包含表情等特殊符号',
							buttons: ['确定']
						}, function (ret, err) {});
					}
				}
			}
		});
	}

	function addListeners() {
		api.addEventListener({
			name: 'viewappear'
		}, function () {
			onPageStart();
		});

		api.addEventListener({
			name: 'viewdisappear'
		}, function (ret, err) {
			onPageEnd();
		});

		api.addEventListener({
			name: 'keyback'
		}, function (ret, err) {
			onPageEnd();
			api.closeWin();
		});
	}
</script>

</html>